package 线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-10-05
 * Time: 8:47
 */
public class demo3 {
    public static void main(String[] args) {
        ExecutorService pool = Executors.newCachedThreadPool();//调用的是静态的方法构造对象,工厂模式
        pool.submit(new Runnable() {//submit里直接传一个Runnable对象
            @Override
            public void run() {
                System.out.println("安排任务1");
            }
        });
        pool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("安排任务2");
            }
        });
    }
}
